using UnityEngine;

[ExecuteInEditMode]
public class readMenuData : ReadTXT
{
	public bool readflag;

	public string levelname;

	public string levelflagname;

	public string levelboxname;

	public string starname;

	public string dtbname;

	public string tdmname;

	public string ffaname;

	public string surname;

	public string planename;

	public string armourname;

	public string gunname;

	public string longname;

	public string multiplename;

	public string missname;

	public string piecename;

	public string achievementname;

	public string dailyname;

	public string boxname;

	public string dailybonusname;

	public MenuDataController menudata;

	private BonusData tempbonus;

	private BoxData tempbox;

	private DailyData tempday;

	private AchievementData tempachi;

	private PieceData temppiece;

	private plane_buy tempplane;

	private weaopn_armour temparmour;

	private weapon_gun tempgun;

	private weapon_miss tempmiss;

	private LevelBox templevelbox;

	private RewardItem tempreitem;

	private LevelStar tempstar;

	private DTBData tempdtb;

	private DropItem temp_drop;

	private TDMData temptdm;

	private FFAData tempffa;

	private SurData tempsur;

	private void Update()
	{
		if (readflag)
		{
			readflag = false;
		}
	}

	public void readdailybonus()
	{
		InitArray(dailybonusname);
		menudata.firstbonusdata.Clear();
		menudata.bonusdata.Clear();
		for (int i = 1; i < GetXlength() - 1; i++)
		{
			tempbonus = null;
			tempbonus = new BonusData();
			tempbonus.type = GetInt(i, 1);
			tempbonus.num = GetInt(i, 2);
			menudata.firstbonusdata.Add(tempbonus);
			tempbonus = null;
			tempbonus = new BonusData();
			tempbonus.type = GetInt(i, 3);
			tempbonus.num = GetInt(i, 4);
			menudata.bonusdata.Add(tempbonus);
		}
	}

	public void readbox()
	{
		InitArray(boxname);
		menudata.Box_data.Clear();
		for (int i = 1; i < GetXlength() - 1; i++)
		{
			tempbox = null;
			tempbox = new BoxData();
			tempbox.id = GetInt(i, 0);
			tempbox.minnum = GetInt(i, 1);
			tempbox.maxnum = GetInt(i, 2);
			tempbox.gailv = GetInt(i, 3);
			menudata.Box_data.Add(tempbox);
		}
	}

	public void readdaily()
	{
		InitArray(dailyname);
		menudata.DayData.Clear();
		for (int i = 1; i < GetXlength() - 1; i++)
		{
			tempday = null;
			tempday = new DailyData();
			tempday.id = GetInt(i, 0);
			tempday.docstr = GetStr(i, 2);
			tempday.rewardtype = GetInt(i, 3);
			tempday.rewardnum = GetInt(i, 4);
			menudata.DayData.Add(tempday);
		}
	}

	public void readachievement()
	{
		InitArray(achievementname);
		menudata.AchiData.Clear();
		for (int i = 1; i < GetXlength() - 1; i += 3)
		{
			tempachi = null;
			tempachi = new AchievementData();
			tempachi.id = GetInt(i, 0);
			for (int j = 0; j < 3; j++)
			{
				tempachi.num[j] = GetInt(i + j, 4);
				tempachi.rewardtype[j] = GetInt(i + j, 5);
				tempachi.rewardnum[j] = GetInt(i + j, 6);
			}
			menudata.AchiData.Add(tempachi);
		}
	}

	public void readpiece()
	{
		InitArray(piecename);
		menudata.piecedata.Clear();
		for (int i = 1; i < GetXlength() - 1; i++)
		{
			temppiece = null;
			temppiece = new PieceData();
			temppiece.id = GetInt(i, 0);
			temppiece.type = GetInt(i, 1);
			temppiece.templateid = GetInt(i, 2);
			temppiece.description = GetStr(i, 3);
			menudata.piecedata.Add(temppiece);
		}
	}

	public void readplane()
	{
		InitArray(planename);
		menudata.PlaneData.Clear();
		for (int i = 1; i < GetXlength() - 1; i++)
		{
			tempplane = null;
			tempplane = new plane_buy();
			tempplane.id = GetInt(i, 0);
			tempplane.name = GetStr(i, 1);
			tempplane.level = GetInt(i, 2);
			tempplane.hp = GetInt(i, 3);
			tempplane.unlocklevel = GetInt(i, 4);
			tempplane.unlocktype = GetInt(i, 5);
			tempplane.unlocknum = GetInt(i, 6);
			tempplane.weapons = GetInt(i, 7);
			tempplane.star = GetFloat(i, 8);
			menudata.PlaneData.Add(tempplane);
		}
	}

	public void readarmour()
	{
		InitArray(armourname);
		menudata.ArmourData.Clear();
		for (int i = 1; i < GetXlength() - 1; i += 10)
		{
			temparmour = null;
			temparmour = new weaopn_armour();
			temparmour.id = GetInt(i, 0);
			temparmour.name = GetStr(i, 1);
			for (int j = 0; j < 10; j++)
			{
				temparmour.hp[j] = GetInt(i + j, 3);
				temparmour.def[j] = GetInt(i + j, 4);
				temparmour.levelupgold[j] = GetInt(i + j, 5);
			}
			temparmour.unlocktype = GetInt(i, 6);
			temparmour.unlocknum = GetInt(i, 7);
			temparmour.planelevel = GetInt(i, 8);
			temparmour.star = GetFloat(i, 9);
			menudata.ArmourData.Add(temparmour);
		}
	}

	public void readgun()
	{
		InitArray(gunname);
		menudata.MachineGunData.Clear();
		for (int i = 1; i < GetXlength() - 1; i += 10)
		{
			tempgun = null;
			tempgun = new weapon_gun();
			tempgun.id = GetInt(i, 0);
			tempgun.name = GetStr(i, 1);
			for (int j = 0; j < 10; j++)
			{
				tempgun.att[j] = GetInt(i + j, 3);
				tempgun.pen[j] = GetInt(i + j, 4);
				tempgun.maxnum[j] = GetInt(i + j, 5);
				tempgun.time[j] = GetFloat(i + j, 6);
				tempgun.levelupgold[j] = GetInt(i + j, 7);
			}
			tempgun.unlocktype = GetInt(i, 8);
			tempgun.unlocknum = GetInt(i, 9);
			tempgun.planelevel = GetInt(i, 10);
			tempgun.star = GetFloat(i, 11);
			menudata.MachineGunData.Add(tempgun);
		}
	}

	public void readlong()
	{
		InitArray(longname);
		menudata.longmissileData.Clear();
		for (int i = 1; i < GetXlength() - 1; i += 10)
		{
			tempgun = null;
			tempgun = new weapon_gun();
			tempgun.id = GetInt(i, 0);
			tempgun.name = GetStr(i, 1);
			for (int j = 0; j < 10; j++)
			{
				tempgun.att[j] = GetInt(i + j, 3);
				tempgun.pen[j] = GetInt(i + j, 4);
				tempgun.maxnum[j] = GetInt(i + j, 5);
				tempgun.time[j] = GetFloat(i + j, 6);
				tempgun.levelupgold[j] = GetInt(i + j, 7);
			}
			tempgun.unlocktype = GetInt(i, 8);
			tempgun.unlocknum = GetInt(i, 9);
			tempgun.planelevel = GetInt(i, 10);
			tempgun.star = GetFloat(i, 11);
			menudata.longmissileData.Add(tempgun);
		}
	}

	public void readmultiple()
	{
		InitArray(multiplename);
		menudata.MultipleData.Clear();
		for (int i = 1; i < GetXlength() - 1; i += 10)
		{
			tempgun = null;
			tempgun = new weapon_gun();
			tempgun.id = GetInt(i, 0);
			tempgun.name = GetStr(i, 1);
			for (int j = 0; j < 10; j++)
			{
				tempgun.att[j] = GetInt(i + j, 3);
				tempgun.pen[j] = GetInt(i + j, 4);
				tempgun.maxnum[j] = GetInt(i + j, 5);
				tempgun.time[j] = GetFloat(i + j, 6);
				tempgun.levelupgold[j] = GetInt(i + j, 7);
			}
			tempgun.unlocktype = GetInt(i, 8);
			tempgun.unlocknum = GetInt(i, 9);
			tempgun.planelevel = GetInt(i, 10);
			tempgun.star = GetFloat(i, 11);
			menudata.MultipleData.Add(tempgun);
		}
	}

	public void readmiss()
	{
		InitArray(missname);
		menudata.YoudaodanData.Clear();
		for (int i = 1; i < GetXlength() - 1; i++)
		{
			tempmiss = null;
			tempmiss = new weapon_miss();
			tempmiss.id = GetInt(i, 0);
			tempmiss.name = GetStr(i, 1);
			tempmiss.num = GetInt(i, 2);
			tempmiss.unlocktype = GetInt(i, 3);
			tempmiss.unlocknum = GetInt(i, 4);
			tempmiss.planelevel = GetInt(i, 5);
			tempmiss.star = GetFloat(i, 6);
			menudata.YoudaodanData.Add(tempmiss);
		}
	}

	public void readlevel()
	{
		InitArray(levelname);
		menudata.levelinfo.Clear();
		menudata.levellockinfo.Clear();
		for (int i = 1; i < GetXlength() - 1; i++)
		{
			level_info level_info = null;
			level_info = new level_info();
			level_info.starid.Add(GetInt(i, 7));
			level_info.starid.Add(GetInt(i, 8));
			level_info.starid.Add(GetInt(i, 9));
			level_info.success_exp = GetInt(i, 10);
			level_info.success_gold = GetInt(i, 11);
			level_info.energy = GetInt(i, 12);
			DropItem dropItem = new DropItem();
			dropItem.dropid = GetInt(i, 13);
			dropItem.gailv = GetInt(i, 14);
			level_info.dropitem.Add(dropItem);
			dropItem = null;
			dropItem = new DropItem();
			dropItem.dropid = GetInt(i, 15);
			dropItem.gailv = GetInt(i, 16);
			level_info.dropitem.Add(dropItem);
			menudata.levelinfo.Add(level_info);
			if (i % 6 == 1)
			{
				levellock levellock = null;
				levellock = new levellock();
				levellock.maxstar = GetInt(i, 17);
				levellock.moneybuy = GetInt(i, 18);
				menudata.levellockinfo.Add(levellock);
			}
		}
	}

	public void readlevel_flag()
	{
		InitArray(levelflagname);
		for (int i = 1; i < GetXlength() - 1; i++)
		{
			menudata.levelinfo[i - 1].levelflag = GetInt(i, 1);
		}
	}

	public void readlevel_box()
	{
		InitArray(levelboxname);
		menudata.levelboxdata.Clear();
		for (int i = 1; i < GetXlength() - 1; i += 5)
		{
			templevelbox = null;
			templevelbox = new LevelBox();
			for (int j = 0; j < 2; j++)
			{
				tempreitem = null;
				tempreitem = new RewardItem();
				tempreitem.typeid = GetInt(i + j, 3);
				tempreitem.num = GetInt(i + j, 4);
				templevelbox.boxone.Add(tempreitem);
			}
			for (int k = 2; k < 5; k++)
			{
				tempreitem = null;
				tempreitem = new RewardItem();
				tempreitem.typeid = GetInt(i + k, 3);
				tempreitem.num = GetInt(i + k, 4);
				templevelbox.boxtwo.Add(tempreitem);
			}
			menudata.levelboxdata.Add(templevelbox);
		}
	}

	public void readlevelstar()
	{
		InitArray(starname);
		menudata.starinfo.Clear();
		for (int i = 1; i < GetXlength() - 1; i++)
		{
			tempstar = null;
			tempstar = new LevelStar();
			tempstar.ID = GetInt(i, 0);
			tempstar.type = GetInt(i, 1);
			tempstar.sontype = GetInt(i, 2);
			menudata.starinfo.Add(tempstar);
		}
	}

	public void readDTB()
	{
		InitArray(dtbname);
		menudata.dtbdata.Clear();
		for (int i = 1; i < GetXlength() - 1; i += 9)
		{
			tempdtb = null;
			tempdtb = new DTBData();
			tempdtb.challdata.openlevel = GetInt(i, 1);
			tempdtb.challdata.energy = GetInt(i, 2);
			tempdtb.planeatt = GetInt(i, 3);
			tempdtb.challdata.exp = GetInt(i, 10);
			tempdtb.challdata.money = GetInt(i, 11);
			tempdtb.challdata.diamond = GetInt(i, 12);
			temp_drop = null;
			temp_drop = new DropItem();
			temp_drop.dropid = GetInt(i, 13);
			temp_drop.gailv = GetInt(i, 14);
			tempdtb.challdata.dropitem = temp_drop;
			tempdtb.challdata.falseexp = GetInt(i, 15);
			tempdtb.challdata.falsemoney = GetInt(i, 16);
			menudata.dtbdata.Add(tempdtb);
		}
	}

	public void readTDM()
	{
		InitArray(tdmname);
		menudata.tdmdata.Clear();
		for (int i = 1; i < GetXlength() - 1; i++)
		{
			temptdm = null;
			temptdm = new TDMData();
			temptdm.challdata.openlevel = GetInt(i, 1);
			temptdm.challdata.energy = GetInt(i, 2);
			temptdm.planeatt = GetInt(i, 3);
			temptdm.challdata.exp = GetInt(i, 4);
			temptdm.challdata.money = GetInt(i, 5);
			temptdm.challdata.diamond = GetInt(i, 6);
			temp_drop = null;
			temp_drop = new DropItem();
			temp_drop.dropid = GetInt(i, 7);
			temp_drop.gailv = GetInt(i, 8);
			temptdm.challdata.dropitem = temp_drop;
			temptdm.challdata.falseexp = GetInt(i, 9);
			temptdm.challdata.falsemoney = GetInt(i, 10);
			menudata.tdmdata.Add(temptdm);
		}
	}

	public void readFFA()
	{
		InitArray(ffaname);
		menudata.ffadata.Clear();
		for (int i = 1; i < GetXlength() - 1; i++)
		{
			tempffa = null;
			tempffa = new FFAData();
			tempffa.challdata.openlevel = GetInt(i, 1);
			tempffa.challdata.energy = GetInt(i, 2);
			tempffa.planeatt = GetInt(i, 3);
			tempffa.challdata.exp = GetInt(i, 4);
			tempffa.challdata.money = GetInt(i, 5);
			tempffa.challdata.diamond = GetInt(i, 6);
			temp_drop = null;
			temp_drop = new DropItem();
			temp_drop.dropid = GetInt(i, 7);
			temp_drop.gailv = GetInt(i, 8);
			tempffa.challdata.dropitem = temp_drop;
			menudata.ffadata.Add(tempffa);
		}
	}

	public void readSur()
	{
		InitArray(surname);
		menudata.surdata.Clear();
		for (int i = 1; i < GetXlength() - 1; i += 20)
		{
			tempsur = null;
			tempsur = new SurData();
			tempsur.challdata.openlevel = GetInt(i, 2);
			tempsur.challdata.energy = GetInt(i, 3);
			temp_drop = null;
			temp_drop = new DropItem();
			temp_drop.dropid = GetInt(i, 9);
			temp_drop.gailv = GetInt(i, 10);
			tempsur.challdata.dropitem = temp_drop;
			menudata.surdata.Add(tempsur);
		}
	}
}
